// 以前 token 令牌，如果存到了本地，每一次都写这么长，太麻烦
// localStorage.setItem(键， 值)
// localStorage.getItem(键)
// localStorage.removeItem(键)

const KEY = 'likede-token'

// 直接用按需导出，可以导出多个
// 但是按需导出，导入时必须 import { getToken } from '模块名导入'

// token
// 获取
export const getToken = () => {
  return localStorage.getItem(KEY)
}

// 设置
export const setToken = (newToken) => {
  localStorage.setItem(KEY, newToken)
}

// 删除
export const delToken = () => {
  localStorage.removeItem(KEY)
}

const USERNAME = 'likede-username'

// name
// 获取
export const getName = () => {
  return localStorage.getItem(USERNAME)
}

// 设置
export const setName = (newName) => {
  localStorage.setItem(USERNAME, newName)
}

// 删除
export const delName = () => {
  localStorage.removeItem(USERNAME)
}

// id
const ID = 'likede-id'
// 获取
export const getID = () => {
  return localStorage.getItem(ID)
}

// 设置
export const setID = (newID) => {
  localStorage.setItem(ID, newID)
}

// 删除
export const delID = () => {
  localStorage.removeItem(ID)
}
